package com.qingfeng.provide.controller;

import com.qingfeng.core.dao.qingfeng.BalanceDetailDao;
import com.qingfeng.core.data.ResultData;
import com.qingfeng.core.entity.qingfeng.BalanceDetail;
import com.qingfeng.core.utils.UuidUtil;
import com.qingfeng.provide.constant.MyConstant;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.Date;

/**
 * @description: 余额明细
 * @author:LWY
 * @date: 2017/11/15 16:05
 * @modified:
 */
@RestController
@RequestMapping("/balance")
public class BalanceDetailController {
    @Autowired
    BalanceDetailDao balanceDetailDao;

    /**
     * 余额明细
     *
     * @param request
     * @return
     */
    @RequestMapping("/detail/{module}")
    public ResultData detail(HttpServletRequest request, @PathVariable Integer module) {
        String user_id = request.getParameter("id");
        String pageNum = request.getParameter("pageNum");
        if (StringUtils.isEmpty(pageNum)) {
            pageNum = "1";
        }
        Page<BalanceDetail> page = balanceDetailDao.findByModuleAndUserOrderByCreateTimeDesc(module, user_id, new PageRequest(Integer.valueOf(pageNum) - 1, MyConstant.getPageSize()));
        return new ResultData(ResultData.SUCCESS, "获取数据成功", page);
    }
}
